from django.test import TestCase
from rest_framework.test import APITestCase
# Create your tests here.
# 1.  编写测试用例，验证之前获取客户端ip、操作系统的 视图是否正常
# 2.  编写测试用例，模拟访问admin后台，状态码200
# class MyTest(TestCase):

    # def test_html(self):
    #     hedaer = {
    #         "REMOTE_ADDR": '127.0.0.1',
    #         "HTTP_USER_AGENT": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
    #     }
    #     response=self.client.get('/index',**hedaer)
    #     self.assertEqual(response.status_code, 200)
    #     self.assertContains(response,'127.0.0.1')
    #     self.assertContains(response,'Windows')
    #     self.assertContains(response,'Chrome')


    # def test_admin(self):
    #     # response=self.client.get('/admin/')
    #     # self.assertEqual(response.status_code,302)
    #     from django.contrib.auth.models import User
    #     user=User.objects.create_superuser('zz','zz@163.com','zhangying3749')
    #     self.client.login(username='zz', password='zhangying3749')
    #     # self.client.force_login(user)
    #     response = self.client.get('/admin/')
    #     self.assertEqual(response.status_code, 200)

class C2Test(APITestCase):
    def test_CourseViewSet(self):
        url='/c2/'
        response=self.client.get(url)
